package com.kly.sc.api.application.controller.blindBox;

import com.kly.sc.api.application.controller.blindBox.request.MatchRequest;
import com.kly.sc.api.application.controller.blindBox.response.BindBoxResponse;
import com.kly.sc.api.application.controller.blindBox.response.PrizeResponse;
import com.kly.sc.api.application.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/api/blindBox")
@Api(value = "/api/blindBox", tags = "盲盒")
public class BlindBoxController {

    @GetMapping("/getPrize")
    @ApiOperation(value = "读取奖励", notes = "读取奖励")
    public Result<PrizeResponse> getPrize(@RequestParam @ApiParam("userCode") String userCode) {
        PrizeResponse response = new PrizeResponse();
        response.setUserCode(userCode);
        response.setPrize(2);
        response.setPrizeCount(3);
        return Result.ok(response);
    }

    @GetMapping("/addPrize")
    @ApiOperation(value = "领取奖励", notes = "领取奖励")
    public Result addPrize(@RequestParam @ApiParam("userCode") String userCode) {
        return Result.ok();
    }

    @GetMapping("/bindBoxInfo")
    @ApiOperation(value = "盲盒是否开启、暧昧次数、流量曝光", notes = "盲盒是否开启、暧昧次数、流量曝光")
    public Result<BindBoxResponse> bindBoxInfo(@RequestParam @ApiParam("userCode") String userCode) {
        BindBoxResponse bindBoxResponse = new BindBoxResponse();
        bindBoxResponse.setHaveBindBox(1);
        bindBoxResponse.setAmbiguousCount(2);
        bindBoxResponse.setHaveFlowExposure(1);
        bindBoxResponse.setHomePageLimit(1);

        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date());
        cal.add(Calendar.HOUR_OF_DAY, 5);
        Date date = cal.getTime();
        bindBoxResponse.setHomePageLimitTime(date);
        return Result.ok(bindBoxResponse);
    }

    @PostMapping("/sendAmbiguous")
    @ApiOperation(value = "发送暧昧礼物", notes = "发送暧昧礼物")
    public Result sendAmbiguous(@RequestParam MatchRequest matchRequest) {
        return Result.ok();
    }

    @PostMapping("/ambiguousMatch")
    @ApiOperation(value = "暧昧礼物match", notes = "暧昧礼物match")
    public Result ambiguousMatch(@RequestParam MatchRequest matchRequest) {
        return Result.ok();
    }

    @GetMapping("/barrage")
    @ApiOperation(value = "弹幕消息", notes = "弹幕消息")
    public Result<List<String>> barrage(@RequestParam @ApiParam("userCode") String userCode) {
        List<String> result = new ArrayList<>();
        result.add("yulian sent out a Flirting gift");
        result.add("yulian1111 sent out a Flirting gift");
        result.add("tudou sent out a Flirting gift");
        return Result.ok(result);
    }
}
